package com.woniuxy.controller;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.Member;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.MemberService;
import io.lettuce.core.Limit;
import io.netty.handler.timeout.ReadTimeoutException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.*;
import java.util.List;

/**
 * Auther: X  <br/>
 * Date: 2021/2/23:14:30  <br/>
 * Description:管理员进行所有用户的查询操作
 */
@RestController
@RequestMapping("Manager")
public class ManagerController {

    @Autowired
    MemberService memberService;

    /**
     * Auther: X  <br/>
     * Date: 2021/2/23:14:32  <br/>
     * Description: 管理员查询所有得用户信息(使用分页展示)
     */
    @RequestMapping("selectAllMes")
    @ResponseBody
    public ResponseEntity<PageInfo<Member>> selectAllMes(Integer page,Integer limit){
        //List<Member> members = memberService.selectAllMes();
        //ResponseEntity<List<Member>> memberEntity=new ResponseEntity<>(members);
        PageInfo<Member> pageInfo= memberService.selectAllMes(page,limit);
        ResponseEntity<PageInfo<Member>> pageInfoResponseEntity = new ResponseEntity<>(pageInfo);
        return pageInfoResponseEntity;
    }

    /**
     * Auther: X  <br/>
     * Date: 2021/2/23:14:33  <br/>
     * Description: 管理员查询信息模糊查询用户信息(使用分页展示)
     */
    @RequestMapping("selectLike")
    @ResponseBody
    public ResponseEntity<PageInfo<Member>> selectLike(String name,Integer page,Integer limit){
        //List<Member> members = memberService.selectLike(a);
        //ResponseEntity<List<Member>> listResponseEntity = new ResponseEntity<>(members);
        PageInfo<Member> pageInfo=memberService.selectLike(name,page,limit);
        ResponseEntity<PageInfo<Member>> pageInfoResponseEntity = new ResponseEntity<>(pageInfo);
        return pageInfoResponseEntity;
    }

}
